﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using WCFMINERP.InnerFactoryContracts.InterFaces;
using WCFMINERP.BLL.InnerFactory;
using WCFMINERP.BLL.PrintShopBill;
using WCFMINERP.InnerFactoryContracts.DataContracts;
using System.Data;




namespace WCFMINERP.InnerFactoryServices
{
    public class InnerFactoryServices : IInnerFactory
    {
        InnerFactoryBLL _bll = new InnerFactoryBLL();
        PrintShopBillBLL _printShopBillBLL = new PrintShopBillBLL();

        /// <summary>
        /// 根据工厂代码获取产品列表
        /// </summary>
        /// <param name="inFactoryId"></param>
        /// <returns></returns>
        public List<ProduceView> NewGetProduceViewList(int inFactoryId)
        {
            return _bll.NewGetProduceViewList(inFactoryId);
        }
        public ProduceView GetProduceViewByPhotoCode(string photoBarcode)
        {
            return _bll.GetProduceViewByPhotoCode(photoBarcode);
        }
        public ProduceView GetProduceViewByOrderCode(string orderBarcode)
        {
            return _bll.GetProduceViewByOrderCode(orderBarcode);
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public UserInfo UserLogin(string userName, string pwd)
        {
            UserInfo userInfo= _bll.UserLogin(userName, pwd);
            return userInfo;
        }

        /// <summary>
        /// 通过激活码找到对应委外商
        /// </summary>
        /// <param name="activeCode"></param>
        /// <returns></returns>
        public OutProcessShop_Info GetOutShopByActiveCode(string activeCode)
        {
            OutProcessShop_Info osInfo = _bll.GetOutShopByActiveCode(activeCode);
            return osInfo;
        }

        /// <summary>
        /// 通过委外商Id获得委外商
        /// </summary>
        /// <param name="outShopId"></param>
        /// <returns></returns>
        public OutProcessShop_Info GetOutShopById(int outShopId)
        {
            return _bll.GetOutShopById(outShopId);
        }

        /// <summary>
        /// 通过产品条码获得委外记录
        /// </summary>
        /// <param name="productBarCode"></param>
        /// <returns></returns>
        public OutProcessRecord_Info GetReCordByCode(string productBarCode)
        {
            OutProcessRecord_Info orInfo = _bll.GetReCordByCode(productBarCode);
            return orInfo;
        }


         /// <summary>
        /// 开始生产
        /// </summary>
        /// <param name="inUser"></param>
        /// <param name="inStrErr"></param>
        /// <param name="inoutRecordId"></param>
        public void StartProduce(int inUser, int inoutRecordId)
        {
            _bll.StartProduce(inUser, inoutRecordId);
        }

        /// <summary>
        /// 结束生产
        /// </summary>
        /// <param name="inUser"></param>
        /// <param name="inStrErr"></param>
        /// <param name="inoutRecordId"></param>
        public void EndProduce(int inUser, int inoutRecordId)
        {
            _bll.EndProduce(inUser, inoutRecordId);
        }


         /// <summary>
        /// 出错暂停生产
        /// </summary>
        /// <param name="inUser"></param>
        /// <param name="inoutRecordId"></param>
        /// <param name="inStrErr"></param>
        public void PauseProduce(int inUser, string inOutBarCode, string inStrErr)
        {
            _bll.PauseProduce(inUser, inOutBarCode, inStrErr);
        }
        /// <summary>
        /// 恢复生产
        /// </summary>
        /// <param name="inUser"></param>
        /// <param name="inStrErr"></param>
        /// <param name="inoutRecordId"></param>
        public void RebootProduce(int inUser, int inoutRecordId)
        {
            _bll.RebootProduce(inUser, inoutRecordId);
        }

        /// <summary>
        ///获取打印信息
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public DataTable GetPrintInfo(string barcode)
        {
            return _bll.GetPrintInfo(barcode);
        }
        public DataTable GetPrintInfoByPhoto(string photoBarcode)
        {
           return _bll.GetPrintInfoByPhotoBarcode(photoBarcode);
        }
         /// <summary>
        /// 检查产品是否存在
        /// </summary>
        /// <param name="productCode"></param>
        /// <returns></returns>
        public bool IsProductExist(string productCode)
        {
            return _bll.IsProductExist(productCode);
        }

        
        /// <summary>
        /// 取得打印报表数据
        /// </summary>
        /// <param name="inGridId"></param>
        /// <param name="inProduct"></param>
        public DataSet GetReportdata(string inProduct, string inGridName)
        {
            return _bll.GetReportdata(inProduct, inGridName);
        }


        
        /// <summary>
        /// 检查照片是否存在
        /// </summary>
        /// <param name="productCode"></param>
        /// <returns></returns>
        public bool IsPhotoExist(string photoBarCode)
        {
            return _bll.IsPhotoExist(photoBarCode);
        }



        //----------------------------------------------------打印商户账单-------------------------------------------------------------

        
        /// <summary>
        /// 通过节点类型获得节点Id
        /// </summary>
        /// <param name="techType"></param>
        /// <returns></returns>
        public  int GettechId(int techType)
        {
            return _printShopBillBLL.GettechId(techType);
        }

         /// <summary>
         /// 扫描接收
         /// </summary>
         /// <param name="barCode"></param>
         /// <param name="OperateUid"></param>
         /// <param name="techId"></param>
         /// <param name="errorMsg"></param>
        /// <returns>0接收成功，1产品全部流程已完成，2产品有错误，3产品生产停止，4产品生产完成，5未知异常，6此产品还未到达本岗位,没有找到状态为1的结点
        /// 7没有找到此产品的相关委外记录,请确认这个产品的流程是否正确!,8该产品未到本岗位，请到客服产看该产品信息!,9在委外记录表中未找到此产品的相关的委外的记录!
        /// 
        /// </returns>
        public int ReceiveBarCode(string barCode, int OperateUid, int techId, out string errorMsg, out OrderInfo_Info orderInfo)
        {
           return  _printShopBillBLL.ReceiveBarCode(barCode, OperateUid, techId, out errorMsg, out orderInfo);
        }


        /// <summary>
        /// 打印账单
        /// </summary>
        /// <param name="curTechId"></param>
        /// <param name="operUid"></param>
        /// <param name="SelectOrderInfo"></param>
        /// <param name="hasForcibePrint"></param>
        /// <param name="inPay"></param>
        /// <returns></returns>
        public SHOP_Bill_Info PrintShopBill(int curTechId, int operUid, List<OrderInfo_Info> SelectOrderInfo, bool hasForcibePrint, int inPay)
        {
            return _printShopBillBLL.NewOrderComplete(curTechId, operUid, SelectOrderInfo, hasForcibePrint, inPay);
        }



        #region IInnerFactory 成员


       

      

        #endregion

       

        #region IInnerFactory 成员


        
        #endregion
    }
}
